package DepartmentManagement

import (
	"MedicalTreatment/global"
	model "MedicalTreatment/model"
	"github.com/gin-gonic/gin"
)

func DepSel(r *gin.Engine) {
	r.POST("/depsel", func(context *gin.Context) {
		var dep model.Department
		var res []model.Department
		if err := context.ShouldBindJSON(&dep); err != nil {
			context.JSON(200, gin.H{
				"Msg": err,
			})
		} else {

			if err := global.DB.Where("name LIKE ?", dep.Name+"%").Find(&res).Error; err != nil {
				context.JSON(200, gin.H{
					"Msg": err,
				})
			} else {
				context.JSON(200, gin.H{
					"Msg": res,
				})
			}

		}
	})
}
